<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<!--只在模块名下面有效 -->
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c"%>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui"%>
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>集团管理</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
	<div class="Wrapper">
		<div>
			<div class="searchArea">
				<form id="searchBar">
					<div class="fieldset1 clearFix">
						<div class="fieldBox">
							<div class="label" style="width: 60px;">集团ID</div>
							<div class="field">
								<input name="groupId" id="groupId" type="text" class="ui-textbox" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label" style="width: 80px;">集团名称</div>
							<div class="field">
								<input name="splNm" id="splNm" type="text" class="ui-textbox" value="">
							</div>
						</div>
						<div class="fieldBox">
							<div class="label" style="width: 80px;">成员名称</div>
							<div class="field">
								<input name="memberNm" id="memberNm" type="text" class="ui-textbox" value="">
							</div>
						</div>

						<div class="fieldBox">
							<div class="label" style="width: 60px;">关键人</div>
							<div class="field">
								<input name="relInfo" id="relInfo" type="text" class="ui-textbox" value="">
							</div>
						</div>

						<div class="clearFix"></div>
						<div class="btnsBox">
							<span id="searchBtn" class="sq-button sq-button-round">查询</span>
							<span id="modifyBtn" class="sq-button sq-button-round">修改</span>
							<span id="clearBtn" class="sq-button sq-button-round">清空</span>

							<span id="searchBtnvisual" class="sq-button sq-button-round">图谱测试visual</span>
							<span id="searchBtnvisualHistory" class="sq-button sq-button-round">图谱visualHistory(历史快照)</span>
							<span id="searchBtngroup" class="sq-button sq-button-round">图谱group</span>
							<span id="searchBtnsearch" class="sq-button sq-button-round">图谱search</span>


							<input id="resetBtn" type="reset" value="重置" class="l-button l-button-reset Hide"/>
						<%--<span onclick="toCancelGroupMemberRelation();" class="sq-button sq-button-round">解除关联</span>--%>
						</div>
					</div>
				</form>
			</div>
			<div id="ligergridDB" class="sq-grid"></div>

			<form id="backConfirm_form" style="display: none;">
				<div class="fieldset1 clearFix">
					<div class="fieldBox">
						<span id="tips"></span>
					</div>
					<div class="fieldBox">
						<div class="label">新集团名称</div>
						<div class="field">
				                <textarea name="newSplNm" id="newSplNm" class="ui-textarea l-textarea"
										  rows="4" cols="60" style="width: 260px;" validate="{required:false,maxlength:200}"></textarea>
						</div>
					</div>
				</div>
			</form>
		</div>
	</div>

	<script type="text/javascript">
	var gridDB = null;
	var form = null ;
	$(function () {
		//initGridDB();//初始化待办列表
        gridDB = $("#ligergridDB").ligerGrid({
            url: '<%=path%>/splGroup/initList.do?splTypCd=1',
            method : 'get',
            columns: [
                { display: '集团ID', name: 'id', minWidth: 10 ,align:'left', enabledSort:false},
                { display: '集团名称', name: 'splName', minWidth: 50 ,align:'left', enabledSort:false},
                /* { display: '关键人', name: 'relInfo', minWidth: 300 , enabledSort:false}, */
                { display: '成员数量', name: 'count', minWidth: 50 ,align:'left', enabledSort:false}, 
                { display: '挂靠敞口合计(元)', name: 'prjOpenTotal', minWidth: 50 ,align:'left', enabledSort:false,
                	render:function (rowdata, rowindex, value){
                		if(rowdata.prjOpenTotal == null){
                			return '0' ;
                		}else{
                			return FormatMoney(rowdata.prjOpenTotal/100)
                		}
                	}	
                }, 
                { display: '经销敞口合计(元)', name: 'splOpenTotal', minWidth: 50 ,align:'left', enabledSort:false,
                	render:function (rowdata, rowindex, value){
                		if(rowdata.splOpenTotal == null){
                			return '0' ;
                		}else{
                			return FormatMoney(rowdata.splOpenTotal/100);
                			//return percentNum(rowdata.splOpenTotal)
                		}
                	}
                }, 
                { display: '担保合计(元)', name: 'guaranteeTotal', minWidth: 50 ,align:'left', enabledSort:false,
                	render:function (rowdata, rowindex, value){
                		if(rowdata.guaranteeTotal == null){
                			return '0' ;
                		}else{

                			return FormatMoney(rowdata.guaranteeTotal/100);
                		}
                	}
                },
                getOpt8Columns(),
                /* { display: '操作', name: '', minWidth: 140 , enabledSort:false,
                    render:function (rowdata, rowindex, value){
                        var h="";
                        h+='<a class="sq-button-hasicon" href="javascript:showSplGroupMembersDetail(';
                        h+="'"+rowdata.id+"','"+rowdata.splNm+"'";
                        h+=")\"><i class='sqBtnIco_1'></i>查看全部成员</a>";
                    }}, */
            ],
            pageSize:10,
            pageSizeOptions: [10, 20, 30, 40, 50, 100],//按照自己的喜好选择不同的页面显示条数
            root:'rows',
            record:'total',
            hideLoadButton : true,
            width: '100%',
            height:'100%',
            heightDiff:-30,
            checkbox:true,
            rownumbers:true,
            fixedCellHeight: false,
        });

        gridDB.setHeight(100);
        //gridDB.options.isSingleCheck=true;

		form = $("#searchBar").ligerForm();

		$("#searchBtn").click(function(event) {
            var data = form.getData();
            console.log(JSON.stringify(data));
            for (name in data){
                gridDB.setParm(name,data[name]);
            };
            gridDB.reload();
        });

		//图谱调用示例  usrId 这个地方与以往不一样 我做了强校验 ，会判断传过来的是否是当前系统登录用户如果不是 都不会展示
		$("#searchBtnvisual").click(function(event) {
			Add_navTab('tab_spl_grp_memb_dev_amt_rankvisual','visual页面调用示例','<%=path%>/knowledgeGraph/init/initGraphVisualPage.do?prjId=190813077165410'+"&c_no=440682197712184313&usrId=1");
		});

		$("#searchBtnvisualHistory").click(function(event) {
			Add_navTab('tab_spl_grp_memb_dev_amt_rankvisualHistory','visualHistory页面调用示例','<%=path%>/knowledgeGraph/init/initGraphVisualHistoryPage.do?prjId=190813077165410'+"&c_no=440682197712184313&usrId=1");
		});
		$("#searchBtngroup").click(function(event) {
			Add_navTab('tab_spl_grp_memb_dev_amt_rankgroup','group页面调用示例','<%=path%>/knowledgeGraph/init/initGraphGroupPage.do?prjId=190813077165410'+"&c_no=440682197712184313&usrId=1");
		});
		$("#searchBtnsearch").click(function(event) {
			Add_navTab('tab_spl_grp_memb_dev_amt_ranksearch','search页面调用示例','<%=path%>/knowledgeGraph/init/initGraphSearch.do?prjId=190813077165410'+"&c_no=440682197712184313&usrId=1");
		});


        $("#modifyBtn").click(function(event) {
            var selectedRows = gridDB.getSelectedRows();
            if (selectedRows.length == 0 || selectedRows.length >1) {
                $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_SELECT_ONLY_A_ROW, SQ_type: "warning"});
                return;
            }
            var id = selectedRows[0].id ;
            var splNm = selectedRows[0].splNm ;
            modifyNewGroupNm(id,splNm);
        });
	});
	
	function percentNum(num) {
        return (Math.round(num  * 100) / 10000.00 ); //小数点后两位百分比
    }
	function getOpt8Columns(){
	    var col8 = {
	       display: '更多操作',
	       isSort: false,
	       width: 300,
	       align:'center',
	       isEllipsis: false,
	       render: function (rowdata, rowindex, value){
	    	   var m="";
               m+='<a class="sq-button-hasicon" href="javascript:showSplGroupMembersDetail(';
               m+="'"+rowdata.id+"','"+rowdata.splNm+"'";
               m+=")\"><i class='sqBtnIco_1'></i>查看全部成员</a>";
               
               var h2="";
               h2+='<a class="sq-button-hasicon" href="javascript:showMessage(';
               h2+="'"+rowdata.id+"','"+5+"'";
               h2+=')"><i class="sqBtnIco_3"></i>集团贷款及担保</a>'
               h2+='<a class="sq-button-hasicon" href="javascript:showMessage(';
               h2+="'"+rowdata.id+"','"+4+"'";
               h2+=')"><i class="sqBtnIco_2"></i>集团经销业务统计</a>';
               
               h2+='<a class="sq-button-hasicon" href="javascript:showMessage(';
               h2+="'"+rowdata.id+"','"+3+"'";
               h2+=')"><i class="sqBtnIco_21"></i>集团经销合作对象</a>';
               
               h2+='<a class="sq-button-hasicon" href="javascript:showMessage(';
               h2+="'"+rowdata.id+"','"+2+"'";
               h2+=')"><i class="sqBtnIco_21"></i>集团挂靠业务统计</a>';
               
               h2+='<a class="sq-button-hasicon" href="javascript:showMessage(';
               h2+="'"+rowdata.id+"','"+1+"'";
               h2+=')"><i class="sqBtnIco_21"></i>集团挂靠合作对象</a>';
   	     	   return m + SQ.dropLinks(h2);
	           
	       }
	   };
		return col8;
	}
	function showMessage(groupId,type){
		if(!groupId){
			return "";
		}
		if(type == 1){
			Add_navTab('tab_spl_grp_memb_dev_amt_rank'+groupId+'1','挂靠合作对象','<%=path%>/grpcfg/splgrpprjbizview/toSplGrpMembDevAmtRank.do?splTypCd=3'+"&groupId="+groupId);
		}else if(type == 2){
			Add_navTab('tab_grp_member_data'+groupId+'2','挂靠业务统计','<%=path%>/grpcfg/splgrpprjbizview/toGrpMemberDataByPage.do?splTypCd=3'+"&groupId="+groupId);
		}else if(type == 3){
			Add_navTab('tab_spl_grp_memb_dev_amt_rank'+groupId+'3','经销合作对象','<%=path%>/grpcfg/splgrpprjbizview/toSplGrpMembDevAmtRank.do?splTypCd=2'+"&groupId="+groupId);
		}else if(type == 4){
			Add_navTab('tab_grp_member_data'+groupId+'4','经销业务统计','<%=path%>/grpcfg/splgrpprjbizview/toGrpMemberDataByPage.do?splTypCd=2'+"&groupId="+groupId);
		}else if(type == 5){
			Add_navTab('tab_grp_member_data'+groupId+'5','贷款及担保','<%=path%>/grpcfg/splgrpprjbizview/toLoanList.do?cstRlCd=1'+"&groupId="+groupId);		
		}else{
			return "";
		}
	}
	
  //修改集团名称
  function modifyNewGroupNm(id,splNm){
      var _id = id;//集团id
      var _splNm=splNm;//集团名称
      if(StringUtils.isEmpty(_id)) return;
      var newSplNm =null;
      var onOk = function (item, Dialog) {
          newSplNm =$("#newSplNm").val();
          var url = '<%=path%>/splGroup/modifySplGroupNm.do';
          var wait_dialog;

          $.ajax({
              type: 'post',
              dataType:'json',
              data:{
                  id:_id,
				  splNm:_splNm,
                  newSplNm:newSplNm
              },
              url: url,
              beforeSend: function(){
                  wait_dialog=top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
              },
              success:function(msg){
                  wait_dialog.close();
                  if(msg.success == 1){
                      top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                      Dialog.hide();
                      gridDB.reload();
                  }else{
                      top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
                  }
              }
          });

      };
      var onCancel = function (item, Dialog) {
          Dialog.hide();
      };

      $.ligerDialog.SQopen({
          width: 400,
          title : '修改集团名称',
          target : $('#backConfirm_form'),
          buttons: [
              {
                  text: "确认", onclick: onOk, type: 'ok', cls: 'l-dialog-btn-ok'
              },
              {
                  text: "取消", onclick: onCancel, type: 'cancel', cls: 'l-dialog-btn-no'
              }
          ]
      });
  }
  
  
 
    //格式化时间
    function renderDate2(rowdata, index, value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }
    
    //查看全部成员
	function showSplGroupMembersDetail(id,name){
		Add_navTab('tab_spl_group_member_info'+id,'集团成员列表','<%=path%>/splGroup/toListPage.do?splTypCd=23'+"&groupId="+id);
	}

    $("#clearBtn").click(function(event) {
        $("#resetBtn").click();  //重置 input-text
        var form = liger.get("searchBar");
        form.setData({  //重置select等特殊表单
            "groupId":"",
            "splNm":"",
            "relInfo":""
        });
    });
</script>

</body>
</html>
